{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 计算两个分布的贝叶斯最优分类边界并画图"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "生成两个由1000个样本组成的二变量高斯分布，分别服从$m_1=[0,2]^T,m_2=[1.5,0]^T$，且具有同样的协方差矩阵$C=\\left[ \\begin{array}{c} 2 & 1 \\\\ 1 & 2 \\end{array} \\right]$，计算两个分布的贝叶斯最优分类边界并画图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "#from numpy.linalg import cholesky\n",
    "import matplotlib.pyplot as plt\n",
    "# 对sequence连续使用function, 如果不给出initial, \n",
    "# 则第一次调用传递sequence的两个元素, \n",
    "# 以后把前一次调用的结果和sequence的下一个元素传递给function. \n",
    "# 如果给出initial, 则第一次传递initial和sequence的第一个元素给function.\n",
    "from functools import reduce"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "sampleNo = 100\n",
    "# 第一个高斯分布参数\n",
    "mu = np.array([[0, 2]])\n",
    "# 第二个高斯分布参数\n",
    "mu1 = np.array([[1.5, 0]])\n",
    "# 协方差矩阵\n",
    "Sigma = np.array([[2, 1], [1, 2]])\n",
    "#R = cholesky(Sigma).T\n",
    "#va,vc = np.linalg.eig(Sigma); R2 = (np.diag(va)**0.5)@vc.T"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 生成高斯分布\n",
    "np.random.multivariate_normal方法用于根据实际情况生成一个多元正态分布矩阵。  \n",
    "def multivariate_normal(mean, cov, size=None, check_valid=None, tol=None)   \n",
    "**mean：**mean是多维分布的均值维度为1；  \n",
    "**cov：**协方差矩阵（协方差基本概念戳这里），注意：协方差矩阵必须是对称的且需为半正定矩阵；  \n",
    "**size：**指定生成的正态分布矩阵的维度（例：若size=(1, 1, 2)，则输出的矩阵的shape即形状为 $1*1*2*N$（N为mean的长度））。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "s1 = np.random.multivariate_normal(mu[0], Sigma, sampleNo) \n",
    "s2 = np.random.multivariate_normal(mu1[0], Sigma, sampleNo)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 得到定义域范围\n",
    "x = range(-100,100,1)\n",
    "# 对Sigma(协方差矩阵)矩阵求逆\n",
    "C = np.linalg.inv(Sigma)\n",
    "w = 2*np.dot(C, mu1.T-mu.T)\n",
    "b = reduce(np.dot, [mu,C,mu.T])- reduce(np.dot, [mu1,C,mu1.T])\n",
    "w0 = (-w[0]/w[1])[0]\n",
    "y= np.dot(w0, x)+(-b/w[1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.legend.Legend at 0x16818d68>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAREAAAD8CAYAAABQOZBmAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJztnXt8VNW5979rkkAUQTFSUBIS0SpVLFVihFKxXlqVUn2PVj1H6Kl6rMXSV6keVC5i9T19jwr21CK2WpDagvSiAlap13pB3yImQBWV1oiERBAwBERumcms94/JhMkwl71nrz1775nn+/n4wcievdces377Wc/z289SWmsEQRByJeT1AARBCDYiIoIgOEJERBAER4iICILgCBERQRAcISIiCIIjREQEQXCEiIggCI4QEREEwRGlXlz0qKOO0jU1NV5cWhAEizQ0NHyqte6X7ThPRKSmpob6+novLi0IggU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hMITmRzDwA9AZeUEqtUUr9yusBWaUzIfwj4Dliycg/Bk1AOhkFfBc4p/P/wZrOJ7rgEyQSEQTBERKJCILgCBERQRAcISIiCIIjREQEQXCEiIggCI4QEREEwREiIoIgOEJERBAER/x/138UTJJLzzIAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 绘制s1的点集\n",
    "plt.plot(*s1.T,'.',label = 's1')\n",
    "# 绘制s2的点集\n",
    "plt.plot(*s2.T,'.',label = 's2')\n",
    "plt.axis('scaled')\n",
    "# 绘制两个分布的均值连线\n",
    "plt.plot(mu[0],mu1[0],'-')\n",
    "# 绘制分离超平面\n",
    "plt.plot(x,y[0],'-')\n",
    "plt.legend()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.2"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": false,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
